<template>
	<view>
		<view class="tabs">
			<view class="tabs-one" @click="changetab(1)">
				<view class="tabs-top" :class="num==1?'color':''">
					我的申请
				</view>
				<view class="tabs-color" :class="num==1?'avtive':''">

				</view>
			</view>
			<view class="tabs-one" @click="changetab(2)">
				<view class="tabs-top" :class="num==2?'color':''">
					我的审批
				</view>
				<view class="tabs-color" :class="num==2?'avtive':''">

				</view>
			</view>

		</view>

		<view class="cont">
			<view class="" v-if="num==1">
				<u-empty
				v-if="empty"
				        mode="list"
				        icon="http://cdn.uviewui.com/uview/empty/list.png"
				>
				</u-empty>
				<view class="box" v-for="item in list" :key="item.id" v-else>
					
					<view class="box-one">
						<view class="box-title">
							{{item.name}}
						</view>
						<view class="box-icon">
							<!-- <u-icon name="arrow-right"></u-icon>img -->
							<img v-show="item.zt == 4" src="../../../static/image/Frame 884.png" alt="">
							<img v-show="item.zt == 5" src="../../../static/image/Frame 885.png" alt="">
						</view>
					</view>
					<view class="box-two">
						<view class="box-two-left">
							<img src="../../../static/image/Frame 880.png" alt="">审核完成，{{item.zt == 4 ? '已完成' :'未通过'}}
							
						</view>
						<view class="box-two-right">
							{{item.updateTime}}
						</view>
					</view>

				</view>
			</view>
			
			<!-- 待我审批 -->
			<view class="" v-if="num==2">
				<u-empty
				v-if="empty"
				        mode="list"
				        icon="http://cdn.uviewui.com/uview/empty/list.png"
				>
				</u-empty>
				<view class="box" v-for="item in list" :key="item.id" v-else>
					<view class="box-one">
						<view class="box-title">
							{{item.name}}
						</view>
						<view class="box-icon">
							<img v-show="item.zt == 4" src="../../../static/image/Frame 884.png" alt="">
							<img v-show="item.zt == 5" src="../../../static/image/Frame 885.png" alt="">
							<!-- <img v-show="item.zt == 4" src="../../../static/image/Frame 884.png" alt="">
							<img v-show="item.zt == 5" src="../../../static/image/Frame 885.png" alt=""> -->
						</view>
					</view>
					<view class="box-two">
						<view class="box-two-left">
							<img src="../../../static/image/Frame 880.png" alt="">申请人：{{item.sqr}}
							
						</view>
						<view class="box-two-right">
							{{item.updateTime}}
						</view>
					</view>
			
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import { getData } from '../../../api/approval.js'
	export default {
		data() {
			return {
				num: 1,
				type:3,
				list:[],
				empty:false
			};
		},
		onShow(){
			  this.getList()
		},
		methods: {
			getList(){
				getData(this.type).then((res) =>{
					if(res.data.length > 0){
						this.list = res.data.reverse()
						this.empty = false
					}else{
						this.empty = true
					}
				})
			},
			changetab(index) {
				this.num = index
				if ( index == 1) {
					this.type = 3
					this.getList()
				}else if( index == 2 ){
					this.type = 4
					this.getList()
				}
			}
		}
	}
</script>

<style lang="scss">
	.avtive {
		background: #1989FA !important;
	}

	.color {
		color: #1989FA !important;
	}

	.tabs {
		height: 90rpx;
		display: flex;
		justify-content: space-around;

		.tabs-one {
			width: 311rpx;
			height: 82rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.tabs-top {
				width: 112rpx;
				height: 44rpx;
				font-size: 28rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #999;
				line-height: 44rpx;

			}

			.tabs-color {
				width: 64rpx;
				height: 6rpx;
				margin-top: 15rpx;
				background: #fff;
			}
		}
	}

	.cont {
		overflow-y: auto;
		box-sizing: border-box;
		height:calc(100vh - 170rpx);
		overflow-y: auto;
		padding: 40rpx 24rpx;
		background-color: #f6f6f6;

		.box {
			padding: 32rpx 48rpx;
			background-color: #fff;
			border-radius: 16px 16px 16px 16px;
			margin-bottom: 20rpx;
			position: relative;
			.box-one {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding-bottom: 20rpx;
				margin-bottom: 20rpx;
				border-bottom: 1px solid #EEEEEE;

				.box-title {
					font-size: 32rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
				}

				.box-icon {
					position: absolute;
					right: 0;
					top: 0;
					img{
						width: 90rpx;
						height: 90rpx;
					}
				}
			}

			.box-two {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 20rpx;
				border-radius: 8px 8px 8px 8px;
				background: #F6F6F6;

				.box-two-left {
					display: flex;
					align-items: center;

					img {
						width: 28rpx;
						height: 28rpx;
					}

					font-size: 24rpx;
					font-family: PingFang SC-Medium,
					PingFang SC;
					font-weight: 500;
					color: #999999;
				}

				.box-two-right {
					
					font-size: 24rpx;
					font-family: PingFang SC-Medium,
					PingFang SC;
					font-weight: 500;
					color: #999999;
				}
			}
		}
	}
</style>
